package aam.model.board;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class BoardDaoImpl implements BoardDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public List<BoardVO> getAllView(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllView", map);
	}
	
	@Override
	public List<BoardVO> getAllViewWithGenre(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewWithGenre", map);
	}

	@Override
	public List<String> getGenreList() throws Exception {
		return this.sqlSessionTemplate.selectList("board.getGenreList");
	}

	@Override
	public String getBoardNameByBoardNo(int boardNo) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardNameByBoardNo", boardNo);
	}

	@Override
	public int getBoardTotalCount(int boardNo) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCount", boardNo);
	}
	
	@Override
	public void updateCount(int no) throws Exception {
		sqlSessionTemplate.update("board.updateCount",no);
	}
	
	@Override
	public BoardVO getContentView(int no) throws Exception {
		return (BoardVO)sqlSessionTemplate.selectOne("board.getContentView",no);
	}

	@Override
	public void write(BoardVO vo) throws Exception {
		sqlSessionTemplate.insert("board.write",vo);
		
	}
	
	@Override
	public void writeFileUpload(BoardVO vo) throws Exception{
		sqlSessionTemplate.insert("board.writeFileUpload",vo);
	}
	
	@Override
	public void writeImageFileUpload(BoardVO vo) throws Exception {
		sqlSessionTemplate.insert("board.writeImageFileUpload", vo);

	}

	@Override
	public List<String> getBoardList() 
	{
		return sqlSessionTemplate.selectList("admin.getBoardList");
	}

	@Override
	public void movePost(BoardVO vo) 
	{
		sqlSessionTemplate.update("admin.movePost", vo);
	}
	
	@Override
	public void updateBoard(BoardVO bvo) throws Exception {
		sqlSessionTemplate.update("board.updateBoard",bvo);
	}
	
	@Override
	public void updateBoardFileUpload(BoardVO bvo) throws Exception {
		sqlSessionTemplate.update("board.updateBoardFileUpload", bvo);
	}

	@Override
	public void deleteBoard(int no) throws Exception {
		sqlSessionTemplate.delete("board.deleteBoard",no);
	}
	@Override
	public List<BoardVO> getAllViewFindByTitle(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByTitle", map);
	}
	@Override
	public List<BoardVO> getAllViewFindByNick(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByNick", map);
	}
	@Override
	public List<BoardVO> getAllViewFindByContent(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByContent", map);
	}

	@Override
	public int getBoardTotalCountBySelectTitle(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectTitle", map);
	}
	@Override
	public int getBoardTotalCountBySelectNick(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectNick", map);
	}
	@Override
	public int getBoardTotalCountBySelectContent(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectContent", map);
	}
	
	@Override
	public List<BoardVO> getAllViewFindByTitleWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByTitleWithGenre", map);
	}

	@Override
	public List<BoardVO> getAllViewFindByNickWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByNickWithGenre", map);
	}

	@Override
	public List<BoardVO> getAllViewFindByContentWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByContentWithGenre", map);
	}

	@Override
	public int getBoardTotalCountBySelectTitleWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectTitleWithGenre", map);
	}

	@Override
	public int getBoardTotalCountBySelectNickWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectNickWithGenre", map);
	}

	@Override
	public int getBoardTotalCountBySelectContentWithGenre(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectContentWithGenre", map);
	}
	
	@Override
	public void updatePointWrite(String memberId) throws Exception {
		sqlSessionTemplate.update("board.updatePointWrite", memberId);
		
	}
	@Override
	public List<BoardVO> getAllViewFindByGenreTitle(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByGenreTitle", map);
	}

	@Override
	public List<BoardVO> getAllViewFindByGenreNick(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByGenreNick", map);
	}

	@Override
	public List<BoardVO> getAllViewFindByGenreContent(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByGenreContent", map);
	}

	@Override
	public int getBoardTotalCountBySelectGenreTitle(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectGenreTitle", map);
	}

	@Override
	public int getBoardTotalCountBySelectGenreNick(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectGenreNick", map);
	}

	@Override
	public int getBoardTotalCountBySelectGenreContent(HashMap map)
			throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectGenreContent", map);
	}

	
	@Override
	public int getGenreNo(String genreName) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getGenreNo", genreName);
	}

	@Override
	public List<BoardVO> getAllViewFindByGenre(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("board.getAllViewFindByGenre", map);
	}

	@Override
	public int getBoardTotalCountBySelectGenre(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.getBoardTotalCountBySelectGenre", map);
	}
	
	//12.19
	@Override
	public List<BoardVO> getAllViewMain() throws Exception {
		return sqlSessionTemplate.selectList("board.getAllViewMain");
	}
	
	@Override
	public List<BoardVO> getAllViewMainByView() throws Exception {
		return sqlSessionTemplate.selectList("board.getAllViewMainByView");
	}

	@Override
	public List<BoardVO> getViewMainByShare() throws Exception {
		return sqlSessionTemplate.selectList("board.getViewMainByShare");
	}
	
	@Override
	public List<BoardVO> getViewMainByReview() throws Exception {
		return sqlSessionTemplate.selectList("board.getViewMainByReview");
	}
	@Override
	public void updatePointFileDown(String id) throws Exception {
		sqlSessionTemplate.update("board.updatePointFileDown",id);
		
	}
	@Override
	public int recommend(HashMap map) throws Exception {
		return this.sqlSessionTemplate.insert("board.recommend", map);
	}

	@Override
	public int unrecommend(HashMap map) throws Exception {
		return this.sqlSessionTemplate.insert("board.unrecommend", map);
	}

	@Override
	public int checkRecommend(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.checkRecommend",map);
	}

	@Override
	public int recommendCount(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.recommendCount", no);
	}

	@Override
	public int unrecommendCount(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("board.unrecommendCount", no);
	}
}
